$(function () {
    // 查询品牌
    $.ajax({
        url:"/purchaseOrderManage/queryBrand",
        type:"post",
        dataType:"json",
        success:function (r) {
            let str = "<option>请选择</option>";
            if (r!=null){
                for (let i = 0; i < r.length; i++) {
                    str += "<option id='"+r[i].brandId+"'>"+r[i].brandName+"</option>"
                }
                $(".brand").html(str);
            }
            $(".brand").html(str);
        }
    })
})

function queryType(a) {
    let brandId = $(a).children("option:selected").attr("id");
    $.ajax({
        url:"/purchaseOrderManage/queryTypeByBrand",
        type: "post",
        data:{"brandId":brandId},
        dataType: "json",
        success:function (r) {
            // console.log(r)
            let str = "<option>请选择</option>";
            if (r!=null){
                for (let i = 0; i < r.length; i++) {
                    str += "<option id='"+r[i].typeId+"'>"+r[i].typeName+"</option>"
                }
                $(a).parent().next().children().html(str);
            }
            $(a).parent().next().children().html(str)
        }
    })

}

function queryModel(a) {
    let typeId = $(a).children("option:selected").attr("id");
    // console.log(typeId)
    $.ajax({
        url:"/purchaseOrderManage/queryModelByType",
        type: "post",
        data:{"typeId":typeId},
        dataType: "json",
        success:function (r) {
            console.log(r)
            let str = "<option>请选择</option>";
            if (r!=null){
                for (let i = 0; i < r.length; i++) {
                    str += "<option id='"+r[i].productId+"'>"+r[i].productModel+"</option>"
                }
                $(a).parent().next().children().html(str);
            }
            $(a).parent().next().children().html(str)
        }
    })

}

function getProductDetail(a) {
    // let productId = $(a).children("option:selected").attr("id");
    $.ajax({
        url:"/purchaseOrderManage/queryProductDetail",
        ty:"post",
        data:{"productId":productId},
        dataType:"json",
        success:function (r) {
            if (r!=null){
                // $(a).parent().next().next().html(r.productUnit);
                // $(a).parent().next().next().next().html(r.productPrice);
            }
        }
    })
}